package com.lancoo.znbkxx.teacher.aibkTestCoach.questionToEvaluation.aibkQuesEvalutionYDPP

import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseFragment
import com.lancoo.znbkxx.teacher.aibkTestCoach.questionToEvaluation.AibkSingleQuesEvaluationActivity
import android.os.Handler
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.QuesEvaluationDetail
import kotlinx.android.synthetic.main.aibk_include_loading_refresh.view.*

class QuesEvaluationFragmentYdpp(
        val activity: AppCompatActivity,
        val quesId: String,
        val startIndex: Int
) : KBaseFragment() {

    private var rootView: View? = null
    var quesEvaluationDetail: QuesEvaluationDetail? = null
    private var isAddView = false

    override fun createLayout(): Int {
        return R.layout.aibk_fragment_model_splitlayout
    }

    override fun initView(view: View?) {
        rootView = view
    }

    private fun showQuestionView(quesEvaluationDetail: QuesEvaluationDetail) {

    }

    override fun setMenuVisibility(menuVisible: Boolean) {
        super.setMenuVisibility(menuVisible)
        if (!isAddView && menuVisible) {

            Handler().postDelayed({

                    val parentActivity: AibkSingleQuesEvaluationActivity? = getActivity() as AibkSingleQuesEvaluationActivity?
                    parentActivity?.getSingleQuesEvaluation(quesId, startIndex)
                    parentActivity?.setDetailListener(object : AibkSingleQuesEvaluationActivity.OnDetailListener {

                        override fun getQuesDetailSuccess(quesEvaluationDetailX: QuesEvaluationDetail) {
                            quesEvaluationDetail = quesEvaluationDetailX
                            isAddView = true
                            rootView!!.RlGifLoading.visibility = View.GONE
                            showQuestionView(quesEvaluationDetail!!)
                        }

                        override fun getQuesDetailFaile() {

                        }

                    })

            }, 500)
        }
    }

}